export class DrawHelper {
    /**
     * @usageNotes
     * ### Manually set the errors for a control
     * ```typescript
     * DrawHelper.line(ctx)({width: 1, color: '#000000', type: 'solid'})({x:0, y: 0}, {x: 100, y: 100})
     * ```
     * @param ctx CanvasRenderingContext2D
     * @returns (start: {x: number, y: number}, end: {x: number, y: number}, option: {width: number, color: string, type: 'solid'}):void
     */
    static line(ctx: CanvasRenderingContext2D) {
        return function(option: {width: number, color: string, type: 'solid'}) {
            return function(start: {x: number, y: number}, end: {x: number, y: number}) {
                ctx.save();
                ctx.beginPath();
                ctx.moveTo(start.x + 0.5, start.y + 0.5);
                ctx.lineTo(end.x + 0.5, end.y + 0.5);
                ctx.lineWidth = option.width;
                ctx.strokeStyle = option.color;
                ctx.stroke();
                ctx.restore();
            }
        }
    }
    static pureDraw<T = void>(ctx: CanvasRenderingContext2D,callback: () => T): T {
        ctx.save();
        ctx.beginPath();
        let val = callback();
        ctx.stroke();
        ctx.restore();
        return val;
    }
}
